import http from "@/api/config/http";
import { DeviceTypeEnum } from "@/enum/system.enum";
import { IQuery, IResponse, ITableResponse } from "@/interface/IAxios";

interface ISkinItem {
  skinIndex: number;
  background: string;
  texture: null;
  preview: string;
}

/* 增删改查接口 */
interface ISkin {
  skinId: string;
  skinName: string;
  category: string | string[];
  priority: number;
  func: string;
  groupsId: string;
  skinList: ISkinItem[];
}

export const listSkins = (query?: IQuery) =>
  http.request<ITableResponse<ISkin>>({
    url: `/theme/skin/list`,
    method: "get",
    params: query
  });
export const addSkins = (data: ISkin) =>
  http.request({
    url: `/theme/skin`,
    method: "post",
    data
  });

export const updateSkins = (data: ISkin) =>
  http.request({
    url: `/theme/skin`,
    method: "put",
    data
  });

export const deleteSkins = (data: string[]) =>
  http.request({
    url: `/theme/skin/${data.join(",")}`,
    method: "delete"
  });

export const detailSkins = (id: string) =>
  http.request<IResponse<ISkin>>({
    url: `/theme/skin/${id}`,
    method: "get"
  });
interface ISendParams {
  groupsId: string;
  skinId: string;
  type: DeviceTypeEnum;
  objects: string[];
}
export const sendBySkin = (data: ISendParams) => {
  return http.request({
    url: `/theme/template/skin`,
    method: "post",
    data
  });
};
export { ISendParams, ISkin, ISkinItem };
